
package networkinterface;

import java.util.Observable;
import java.util.Observer;

import chatController.ChatController;

import model.SharingFiles;
import model.SharingMessages;
import model.SystemState;
import model.Users;


/**
 * @author Michael & Pierre
 */
/**
 * Abstract class which is the network interface of the system
 */
public abstract class ChatNI implements Observer {
	
	/**
	 * Remote port where the messages will be sent
	 */
	protected static final int PORT = 21000;
	/**
	 * Local port where the messages will be received
	 */
	protected static final int LISTEN_PORT = 21000; //not equal to PORT when chats are running on same computer
	/**
	 * Remote port where the files will be sent
	 */
	protected static final int FILE_PORT = 22000;
	/**
	 * Local port where the files will be received
	 */
	protected static final int FILE_RECVPORT = 22000;//not equal to File_PORT when chats are running on same computer
	/**
	 * Broadcast address
	 */
	protected static final String BROADCAST = "255.255.255.255";
	
	protected static Users users;
	protected static ChatController chatController;
	protected static SharingMessages sharingMessages;
	protected static SharingFiles sharingFiles;
	protected static SystemState state;
	
	/**
	 * @param chatController Controller of the chatSystem
	 * @param users model for users management
	 * @param sharingMessages model for sharing chat messages management
	 * @param sharingFiles model for sharing files management
	 * @param state model for system state management
	 */
	public ChatNI(ChatController chatController, Users users, SharingMessages sharingMessages, 
					SharingFiles sharingFiles, SystemState state) {
		ChatNI.chatController = chatController;
		ChatNI.users = users;
		ChatNI.sharingMessages = sharingMessages;
		ChatNI.sharingFiles = sharingFiles;
		ChatNI.state = state;
	}
	
	/**
	 * Abstract method which do what the NI has to do according to the model's changes
	 * @param o model which has launched the update
	 * @param arg object given by the model
	 */
	public abstract void update(Observable o, Object arg);

}
